from django.shortcuts import render
from django.http import HttpResponse, JsonResponse
import os
from server import settings


# Create your views here.

def index(request):
    parent_dir = settings.BASE_DIR
    p_parent_dir = request.GET.get('parent_dir', '')
    if p_parent_dir:
        parent_dir = parent_dir + os.path.sep + p_parent_dir
    print(parent_dir)
    listdir = os.listdir(parent_dir)
    sub_file_list = [(d, os.path.isdir(d)) for d in listdir]
    return JsonResponse(sub_file_list, safe=False)
